package com.faxsun.controller.account;

import org.broadleafcommerce.core.web.controller.account.CustomerAddressForm;
import org.broadleafcommerce.profile.core.domain.Address;
import org.broadleafcommerce.profile.core.domain.PhoneImpl;

import com.faxsun.profile.core.domain.FSAddress;
import com.faxsun.profile.core.domain.FSAddressImpl;
import com.faxsun.profile.core.domain.FSReceiverImpl;

public class FSCustomerAddressForm extends CustomerAddressForm {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2093514492680519554L;
	protected Address address = new FSAddressImpl();

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		if (address.getPhonePrimary() == null) {
			address.setPhonePrimary(new PhoneImpl());
		}
		FSAddress fsAddress = (FSAddress) address;
		if (fsAddress.getReceiver() == null) {
			fsAddress.setReceiver(new FSReceiverImpl());
		}
		this.address = address;
	}

}
